import { Fragment } from '@/components/Fragment'; import { Card, View, Flex, Text, Expander, ExpanderItem, } from '@aws-amplify/ui-react'; import { Example, ExampleCode } from '@/components/Example'; import { ComponentStyleDisplay } from '@/components/ComponentStyleDisplay'; import ThemeExample from '@/components/ThemeExample.mdx'; import { CardDemo } from './demo'; import { DefaultCardExample, CardThemeExample, CardStylePropsExample, CardClassNameExample, CardAsExample, CardVariationsExample, } from './examples'; ## Demo ## Usage The Card component will include basic styling but the form of the Card component will come from the content passed into it. ```jsx file=./examples/DefaultCardExample.tsx ``` ### Variations ```jsx file=./examples/CardVariationsExample.tsx ``` ### Set rendered HTML element The Card component renders as a `div` by default. You can change the HTML element rendered by Card with the `as` property. ```jsx file=./examples/CardAsExample.tsx ``` ## Customization ```tsx file=./examples/CardThemeExample.tsx ``` ### Target classes ### CSS To override styling on all Cards, you can set the Amplify CSS variables or use the built-in `.amplify-card` class. Thick Bordered Card ```css /* styles.css */ :root { --amplify-components-card-border-color: red; --amplify-components-card-border-width: 3px; } /* OR */ .amplify-card { border: 3px solid red; } ``` To replace _all_ the Card styling, unset it: ```css .amplify-card { all: unset; /* Add your styling here*/ } ``` ### Local styling To override styling on a specific Card, you can use a class selector or style props. _Using a class selector:_ ```jsx file=./examples/CardClassNameExample.tsx ``` _Using style props:_ ```jsx file=./examples/CardStylePropsExample.tsx ``` ### Default theme ```ts file=../../../../../../packages/ui/src/theme/tokens/components/card.ts ```